<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!doctype html>
<html lang="zh-CN">
<head>
<meta content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" name="viewport" />
<meta charset="utf-8">
<title>外部用户分享红包脚本生成</title>
</head>
<body>
    <h1>外部用户分享红包生成脚本</h1><hr/>
	<form method="post" id="scriptForm" action="#" enctype="multipart/form-data">
	    <table>
	    	<tr>
	    		<td>红包名称&nbsp;&nbsp;：</td>
	    		<td><input type="text" name="packetName" id="packetName" size="20" /></td>
	    	</tr>
	    	<tr>
	    		<td>红包总额&nbsp;&nbsp;：</td>
	    		<td><input type="text" name="packetTotalAmount" id="packetTotalAmount" size="20" /></td>
	    	</tr>
	    	<tr>
	    		<td>分割总数&nbsp;&nbsp;：</td>
	    		<td><input type="text" name="splitCount" id="splitCount" size="20" /></td>
	    	</tr>
	    	<tr>
	    		<td>分割金额<span style="color: #EE0000">*</span>：</td>
	    		<td><input type="text" name="packetAmount" id="packetAmount" size="20" /></td>
	    	</tr>
	    	<tr>
	    		<td>用户文件<span style="color: #EE0000">*</span>：</td>
	    		<td><input type="file" name="readFile" id="readFile" size="20" /></td>
	    	</tr>
	    	<tr><td>&nbsp;</td></tr>
	    	<tr>
	    		<td><button id="btnDownLoad" class="btnDownLoad" 
	    	     onclick="window.open('../../excel/external_user_template.xlsx')">下载模板</button>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	    	    <td><button id="btnStartCreate" class="btnStartCreate">生成脚本</button></td>
	    	 </tr>
	    </table>
	    <br/><br/>
    </form>
    <hr/>
    <p style="font-size:12px;color: #CDC9C9;">
    	模板文件：必须按照模板文件录入相关数据，生成脚本文件名称与选择文件名称相同(sql和txt文件)!<br/>
                     生成目录：${defaultDir}
    </p>
	<script src="../static/jquery-1.11.0.js"></script>
	<script type="text/javascript">
		$(function(){
			 $("#btnStartCreate").click(function(){
				if (!$('#packetAmount').val()) {
					alert('分割金额不能为空!');
					return;
				}
				if (!$('#readFile').val()) {
					alert('用户文件不能为空!');
					return;
				}
				$.ajax({
					async:false,
				    url: 'generate_user_share_script.htm',
				    type: 'POST',
				    cache: false,
				    data: new FormData($('#scriptForm')[0]),
				    processData: false,
				    contentType: false,
				    dataType:"json",
				    beforeSend: function(){
			            uploading = true;
			        },
				    success : function(data) {
				    	alert(data.resMsg);
				    }
				});
			 });
		 });
	</script>
</body>
</html>
